import Vue from 'vue'
import Router from 'vue-router'
// 三级路由
// import Case1 from './views/pages/consult/conponents/successCase/components/Case1'
// import Case2 from './views/pages/consult/conponents/successCase/components/Case2'
// 二级路由
import Map from './views/common/Map'
import Menu from './views/pages/menu/Menu'
import ActivityDetails from './views/pages/activity/ActivityDetails'
import Join from './views/pages/consult/conponents/Join'
import SuccessCase from './views/pages/consult/conponents/successCase/SuccessCase'
import Problem from './views/pages/consult/conponents/Problem'
import ConsultSon from './views/pages/consult/conponents/ConsultSon'
import Term from './views/pages/consult/conponents/Term'
// 一级路由
const Home = () => import('./views/pages/home/Home')
const Activity = () => import('./views/pages/activity/Activity')
const Consult = () => import('./views/pages/consult/Consult')
const About = () => import('./views/pages/about/About')

Vue.use(Router)

export default new Router({
  mode: 'history',
  base: process.env.BASE_URL,
  routes: [
    {
      path: '*',
      redirect: '/home'
    },
    {
      path: '/home',
      name: 'home',
      component: Home,
      meta: {
        showFooter: true
      }
    },
    {
      path: '/activity',
      name: 'activity',
      component: Activity,
      meta: {
        showFooter: true
      }
    },
    {
      path: '/activityDetails/:id',
      name: 'activityDetails',
      component: ActivityDetails,
      meta: {
        showFooter: false
      }
    },
    {
      path: '/consult',
      name: 'consult',
      component: Consult,
      meta: {
        showFooter: true
      },
      redirect: '/consult/join',
      children: [
        {
          path: 'join',
          name: 'join',
          component: Join,
          meta: {
            showFooter: true
          }
        },
        {
          path: 'successCase',
          name: 'successCase',
          component: SuccessCase,
          meta: {
            showFooter: true
          }
          // redirect: '/consult/successCase',
          // children: [
          //   {
          //     path: 'case1',
          //     name: 'case1',
          //     component: Case1
          //   },
          //   {
          //     path: 'case2',
          //     name: 'case2',
          //     component: Case2
          //   }
          // ]
        },
        {
          path: 'problem',
          name: 'problem',
          component: Problem,
          meta: {
            showFooter: true
          }
        },
        {
          path: 'consultSon',
          name: 'consultSon',
          component: ConsultSon,
          meta: {
            showFooter: true
          }
        },
        {
          path: 'term',
          name: 'term',
          component: Term,
          meta: {
            showFooter: true
          }
        }
      ]
    },
    {
      path: '/about',
      name: 'about',
      component: About,
      meta: {
        showFooter: true
      }
    },
    {
      path: '/menu/:id',
      name: 'menu',
      component: Menu,
      meta: {
        showFooter: true
      }
    },
    {
      path: '/map',
      name: 'map',
      component: Map,
      meta: {
        showFooter: false
      }
    }
  ],
  // 滚动行为
  scrollBehavior (to, from, savedPosition) { // scrollBehavior 方法接收 to 和 from 路由对象。第三个参数 savedPosition 当且仅当 popstate 导航 (通过浏览器的 前进/后退 按钮触发) 时才可用。
    if (savedPosition) {
      return savedPosition
    } else {
      return { x: 0, y: 0 }
    }
  }
})
